<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .btn1{
            background-color: white;
        }
        .btn2{
            background-color: green;
        }
        .btn3{
            background-color: orange;
        }
    </style>
</head>
<body>
    <div id="app">
        <tem :tochild='[s,btns]'></tem>
        <button :class="btn1" @click='toson1'>{{wenzi.w1}}</button>
        <button :class="btn2" @click='toson2'>{{wenzi.w2}}</button>
        <button :class="btn3" @click='toson3'>{{wenzi.w3}}</button>
    </div>
    <template id="tem">
        <div>
            <button :class=[tochild[1]]>{{tochild[0]}}</button>
        </div>
    </template>
    <script src="../vue.js"></script>
    <script>
        let tem={
            template:'#tem',
            props: ['tochild'],
        }
        new Vue({
            el:'#app',
            components: {
                tem,
            },
            data () {
                return {
                    wenzi:{
                        w1:'默认',
                        w2:'成功',
                        w3:'警告',
                    },
                    s:'默认',
                    btn1:'btn1',
                    btn2:'btn2',
                    btn3:'btn3',
                    btns:'',
                }
            },
            methods: {
                toson1(){
                    let b1=document.querySelector('.btn1');
                    this.s=b1.innerHTML;
                    this.btns=this.btn1;
                },
                toson2(){
                    let b1=document.querySelector('.btn2');
                    this.s=b1.innerHTML;
                    this.btns=this.btn2;
                },
                toson3(){
                    let b1=document.querySelector('.btn3');
                    this.s=b1.innerHTML;
                    this.btns=this.btn3;
                },
            }
        })
    </script>
</body>
</html>